package com.mofang.powerdekorhelper.utils;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.mofang.powerdekorhelper.R;


/**
 * Created by luofei on 2017/8/16 0016.
 */

public class GlideLoader {

    private static GlideLoader glideImageLoader;
    private static Context mContext;

    public static GlideLoader getInstance(Context context) {
        if (glideImageLoader == null) {
            glideImageLoader = new GlideLoader();
        }
        mContext = context;

        return glideImageLoader;
    }

    public void loadImage(String url, ImageView myImageView) {
        Glide.with(mContext)
                .load(url)
                //.placeholder(R.mipmap.ic_launcher)
                .dontAnimate()
                .centerCrop()
                .error(R.mipmap.ic_launcher)
                .into(myImageView);
    }

    public void loadCircleImage(String url, ImageView myImageView, Drawable failDrawable) {

        GlideCircleTransform glideCircleTransform = new GlideCircleTransform(mContext);

        Glide.with(mContext)
                .load(url)
                .placeholder(R.mipmap.default_user_head)
                .error(R.mipmap.ic_launcher)
                .crossFade()
                .bitmapTransform(glideCircleTransform)
                .into(myImageView);
    }
}
